def check(a):
    s = []
    c1 = ['(', '[', '{', '<']
    c2 = [')', ']', '}', '>']

    for n1 in a:
        if n1 in c1:
            s.append(n1)
        elif n1 in c2:
            if not s:
                return False
            n2 = s.pop()
            if c1.index(n2) != c2.index(n1):
                return False
    return len(s) == 0
a = input()
m = check(a)
print(m)
